﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace DWF.Studio.Plugin.Contract
{
    /// <summary>
    /// 插件基类
    /// </summary>
    [Serializable]
    public abstract class PluginBase
    {
        public PluginBase(IPluginInfo pluginInfo)
            : base()
        {
            this.PluginInfo = pluginInfo;


        }

        /// <summary>
        /// 插件信息
        /// </summary>
        public IPluginInfo PluginInfo
        {
            get;
            private set;
        }

        /// <summary>
        /// 执行
        /// </summary>
        public abstract void Excute();

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="args"></param>
        public abstract void Initialize(PluginParameters args);

        /// <summary>
        /// 获取本地化字符串
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual string GetLocalizedString(string key)
        {
            return key;
        }

        public virtual async Task<string> GetLocalizedStringAsync(string key)
        {
            string result = null;
            await Task.Run(() => { result = GetLocalizedString(key); });

            return result;
        }
    }
}
